package com.atguigu.chapter05.transform;

import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * Author: Pepsi
 * Date: 2023/7/27
 * Desc:
 */
public class Flink02_filter {
    public static void main(String[] args) {
        Configuration conf = new Configuration();
        conf.setInteger("rest.port",1000);
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(conf);
        env.setParallelism(1);

        // todo 取出集合中的奇数
        env.fromElements(1,2,3,4,5)
//                .filter(new FilterFunction<Integer>() {
//                    @Override
//                    public boolean filter(Integer ele) throws Exception {
//                        if (ele%2 !=0){
//                            return true;
//                        }else {
//                            return false;
//                        }
//                    }
//                })
                .filter(ele-> ele%2!=0)
                .print();

        try {
            env.execute();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
